/**
* 文字不间断滚动插件
*/
(function($) {
	
	$.fn.textSlider = function(){
        roll.init(this);
    }; 
    
    var roll = {
    	init:function(obj,args){
			return (function(){
				
				//hide the scrollbar
				obj.css("overflow", "hidden");
				
				roll.bindEvent(obj,args);
				
				//wrap dt:dd pairs in divs
				obj.children().filter("div").each(function() {

					var div = $(this), container = $("<div>");

					div.next().appendTo(container);
					div.prependTo(container);

					container.appendTo(obj);
				});
				
				//start the ticker
				animator(obj.children(":first"));
			})();
		},
		bindEvent:function(obj,args){
			obj.hover(
				function(){
					obj.children().stop();
				},function(){
					animator(obj.children(":first"));
				}
			);
		}
    }
    
	//animator function
	function animator(currentItem) {

		//work out new anim duration
		var distance = currentItem.height();
		duration = (distance + parseInt(currentItem.css("marginTop"))) / 0.025;

		//animate the first child of the ticker
		currentItem.animate({
			marginTop : -distance
		}, duration, "linear", function() {

			//move current item to the bottom
			currentItem.appendTo(currentItem.parent()).css("marginTop", 0);

			//recurse
			animator(currentItem.parent().children(":first"));
		});
   };
})(jQuery);